package edu.nyp.locationservicesapp.utils.retrofit;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Describe:
 * User:Gaolei  gurecn@gmail.com
 * Date:2018/8/1
 * I'm glad to share my knowledge with you all.
 */
public class GoogleAPIService {
    private static final String GOOGLE_SERVICE_API_KEY  = "AIzaSyBtkg6dfLaLym_UgfUJDXm4XRVA9tB5wUw";

    private Retrofit retrofit;

    public GoogleAPIService() {

        retrofit = new Retrofit.Builder()
                .baseUrl("https://maps.googleapis.com/")
                .addConverterFactory(GsonConverterFactory.create()) // 加上这句话
                .build();

    }

    public void getPoi(double lat, double lng, int radius, String name, Callback<GooglePoiBean> callback) {

        GoogleMapApi googleMapApi = retrofit.create(GoogleMapApi.class);
        Call<GooglePoiBean> googlePoiBeanCall = googleMapApi.listRepos(lat + "," + lng, radius, name, GOOGLE_SERVICE_API_KEY);
        googlePoiBeanCall.enqueue(callback);

    }
}
